// custom-tab-bar/index.js
Component({


  /**
   * 组件的初始数据
   */
  data: {
    active: 0,
		list: [
			{
				icon: 'home-o',
				text: '首页',
				url: '/pages/home/home'
			},
			{
				icon: 'search',
				text: '分类',
				url: '/pages/classify/classify'
			},{
        icon: 'shopping-cart-o',
				text: '购物车',
				url: '/pages/shoppingcar/shoppingcar'
      },{
        icon: 'contact',
				text: '我的',
				url: '/pages/myself/myself'
      }
		]
  },
  methods: {
    
    onChange(event) {
			this.setData({ active: event.detail });
			if(event.detail === 2){
				wx.navigateTo({
					url: '/pages/cart_detail/index',
				})
			}else{
				wx.switchTab({
					url: this.data.list[event.detail].url
				});
			}
			
		},

		init() {
			const page = getCurrentPages().pop();
			this.setData({
				active: this.data.list.findIndex(item => item.url === `/${page.route}`)
			});
		}
	
  }
})
